package com.liy.cloud.common.ext.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liy.framework.common.utils.Tools;
import com.liy.framework.common.vo.BaseVO;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;
import java.util.Map;

/**
 * @Auther: libs
 * @Date: 2018/6/13 15:44
 * @Description:
 */
@JsonIgnoreProperties({"language", "tempField", "dateTimeQuery", "dateTimeQueryMap"})
public class ExtBaseVO<PK>  extends BaseVO<PK> {

    private String dateTimeQuery;
    private Map<String, Object> dateTimeQueryMap;

    /**
     * 过滤条件,map中key为过滤字段,value为过滤值
     */
    private Map<String, List<String>> filterMap;
    private String filterMapJsonStr; //用Json字符串方式接收前端传过来的filterMap

    /**
     * 排序方式，map中key为排序字段，value为排序方式，【升序：asc 或 ascending，降序：desc 或 descending】
     */
    private Map<String,String> sortMap;
    private String sortMapJsonStr; //用Json字符串方式接收前端传过来的sortMap

    public Map<String, List<String>> getFilterMap() {
        return filterMap;
    }

    public void setFilterMap(Map<String, List<String>> filterMap) {
        this.filterMap = filterMap;
        this.filterMapJsonStr = JSONObject.toJSONString(filterMap);
    }

    public String getFilterMapJsonStr() {
        return filterMapJsonStr;
    }

    public void setFilterMapJsonStr(String filterMapJsonStr) {
        this.filterMapJsonStr = filterMapJsonStr;
        this.filterMap = (Map<String, List<String>>)JSONObject.parse(filterMapJsonStr);
    }

    public Map<String, String> getSortMap() {
        return sortMap;
    }

    public void setSortMap(Map<String, String> sortMap) {
        this.sortMap = sortMap;
        this.sortMapJsonStr = JSONObject.toJSONString(sortMap);
    }

    public String getSortMapJsonStr() {
        return sortMapJsonStr;
    }

    public void setSortMapJsonStr(String sortMapJsonStr) {
        this.sortMapJsonStr = sortMapJsonStr;
        this.sortMap = (Map<String, String>)JSONObject.parse(sortMapJsonStr);
    }

    public String getDateTimeQuery() {
        return dateTimeQuery;
    }

    public void setDateTimeQuery(String dateTimeQuery) {
        this.dateTimeQuery = dateTimeQuery;
        if(!Tools.StringIsNullOrSpace(dateTimeQuery)) {
            this.dateTimeQueryMap = (Map<String,Object>) JSON.parse(dateTimeQuery);
        }
    }

    public Map<String, Object> getDateTimeQueryMap() {
        return dateTimeQueryMap;
    }

    public void setDateTimeQueryMap(Map<String, Object> dateTimeQueryMap) {
        this.dateTimeQueryMap = dateTimeQueryMap;
    }
}
